Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds one more test to challenge 3.js of js2 to catch Nx0 array errors #377

Closed
wants to merge 1 commit into from

Conversation

isam007
Copy link

@isam007 isam007 commented Dec 23, 2021

Problem

Closes issue #376.

Currently this solution to challenge 3 passes all the tests and gets accepted despite the range error.
image
image

Solution

Additional test added to test the Nx0 array:
image

@@ -19,4 +19,8 @@ describe('Generate 2D array', () => {
const result = solution(1, 5)
expect(result).toEqual([[0, 0, 0, 0, 0]])
})
it('should generate 3x0 array', () => {
const result = solution(3, 0)
expect(result).toEqual([0],[0],[0])
Copy link
Collaborator

@anthonykhoa anthonykhoa Dec 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are missing the array that the other arrays are contained in.
toEqual([0],[0],[0]) should be toEqual([[0],[0],[0]]).

Another issue to fix is the actual expected output.

The problem description says Every element in the array is an array that is equal to the length of the second input number. All values in the array is 0.

If the length of second input number is 0, then shouldn't the array length correspondingly be 0? Looks like [[0],[0],[0]] would be wrong because each array in that array of arrays has a length of one.

So solution(3, 0) should output [[], [], []]

Copy link
Collaborator

@anthonykhoa anthonykhoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update expected output

@songz
Copy link
Contributor

songz commented Jun 7, 2022

Closing - old

@songz songz closed this Jun 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants